package com.seu.algorithms.sorting.insertion;

import com.seu.algorithms.sorting.SortTestHelper;

import java.util.Arrays;

/**
 * 插入排序和选择排序的性能测试比较
 *
 * @author liangfeihu
 * @since 2018/12/8 17:54
 */
public class Main {

    /**
     * 比较SelectionSort和InsertionSort两种排序算法的性能效率
     * 此时，插入排序比选择排序性能略低
     */
    public static void main(String[] args) {
        int N = 20000;
        System.out.println("Test for random array, size = " + N + " , random range [0, " + N + "]");

        Integer[] arr1 = SortTestHelper.generateRandomArray(N, 0, N);
        Integer[] arr2 = Arrays.copyOf(arr1, arr1.length);

        SortTestHelper.testSort("com.seu.algorithms.sorting.selection.SelectionSortV2", arr1);
        SortTestHelper.testSort("com.seu.algorithms.sorting.insertion.InsertionSort", arr2);
    }

}
